
import 'dart:convert';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_2d_amap/flutter_2d_amap.dart';
import 'package:flutterlib/common/constants/constants.dart';
import 'package:flutterlib/common/utils/navigator_utils.dart';
import 'package:flutterlib/common/utils/utils.dart';
import 'package:flutterlib/widgets/bussiness/search_bar.dart';
import 'package:intl/intl.dart';
import 'package:thrio/thrio.dart';

class Page extends StatefulWidget {
  final String address;
  final String lon;
  final String lat;

  const Page({Key key, this.address, this.lon, this.lat}) : super(key: key);
  @override
  _PageState createState() => _PageState();
}

class _PageState extends State<Page> {
  
  AMap2DController _aMap2DController;

  @override
  void dispose() {
    super.dispose();
  }
  
  @override
  void initState() {
    super.initState();
    /// iOS配置key
    if (defaultTargetPlatform == TargetPlatform.iOS) {
      Flutter2dAMap.setApiKey('ad450535fcf6bc91e0dfa422c85751d5');
    }
  }
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      appBar: AppBar(
      backgroundColor: QuhuiColors.mainBackgroundColor,
      title: Text(widget.address, style: QuhuiConstant.normalTextBold),
      leading: MyBackButton(
        color: Colors.black,
      ),
    ),
      body: SafeArea(
        child: Column(
          children: <Widget>[
            Expanded(
              flex: 9,
              child: AMap2DView(
                onAMap2DViewCreated: (controller) {
                  _aMap2DController = controller;
                  trueDebugPrint("fluttermap ${widget.lat},${widget.lon}");
                  _aMap2DController.move(widget.lat, widget.lon);
                },
              ),
            ),

          ],
        ),
      ),
    );
  }
}


